<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>	
	<script language="javascript" src="<%=contextPath%>/js/func.js"type=""></script>
	<script type="text/javascript" src="<%=contextPath%>/js/My97DatePicker/WdatePicker.js"></script>
	<script type="text/javascript">
	Ext.onReady(function(){
		var whichmenu = $("#searchBean.con20").val();
		var tb = new Ext.Toolbar({
		    renderTo: Ext.get('tbar'),
		    items: [
		        {
		            text: '查询',
		             icon:"<%=contextPath%>/" + "images/query.gif",
		             //hidden:<%=session.getAttribute("btn_add_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>,
		             handler:cmt
		        }, {
		            text: '新建',
		            icon:"<%=contextPath%>/" + "images/tishi.png",
		            //hidden:<%=session.getAttribute("btn_add_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>,
		            handler:function() {
		            	toDetail('0',whichmenu)
		            }
		        }, {
		            text: '提交',
		            icon:"<%=contextPath%>/" + "images/pass.gif",
		            //hidden:<%=session.getAttribute("btn_add_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>,
		            handler:function() {
		            	toConfirm('2');
		            }
	        	},{
					text: '提交工区审核',
					icon:"<%=contextPath%>/" + "images/pass.gif",
					handler:function(){
						toConfirm('3');
					}
				},{
					text: '审核通过',
					icon:"<%=contextPath%>/" + "images/pass.gif",
					handler:function(){
						toConfirm('4');
					}
				},{
					text: '作废',
					icon:"<%=contextPath%>/" + "images/pass.gif",
					handler:function(){
						toConfirm('5');
					}
		        },{
		            text: '删除',
		            icon:"<%=contextPath%>/" + "images/delete.gif",
		           //hidden:<%=session.getAttribute("btn_add_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>,
		            handler:deleteIt
		        },'-',
				{
				     text: '清空',
				     icon:"<%=contextPath%>/images/clear.png",
				     handler:resetForm
				}]
		});
	});
	</script>
  </head>
  <body>
  <div id ='tbar'></div>
		<form id="frmM" class="ct" name="frmM" method="POST" action="">
			<input type="hidden" id="hiddenids" name="hiddenids" value="${hiddenids}"/>
			<input type="hidden" name="searchBean.displayFlag" value="${searchBean.displayFlag}"/>
			<input type="hidden" name="searchBean.con1" id="searchBean.con1" value="${searchBean.con1}" >
			<input type="hidden" name="searchBean.con20" id="searchBean.con20" value="${searchBean.con20}" >
			<input type="hidden" name="conditionHtml" />
			<table width="100%" id="contab" >
				<tr>
					<th class="ct">方案名称：</th>
					<td>
						<input type="text" name="searchBean.con4" id="searchBean.con4" />
					</td>
				</tr>
			</table>
		<hr>
		<table width="100%" id="listtab">
    		<tr>
    			<th width="10%">
	           <!--input name="chkAll" type="checkbox" id="chkAll"
				onclick="javascript:checkAll(this.form, 'id');" value="checkbox" -->
				</th>
				<th class="ct" >方案名称</th>
				<th class="ct">审核</th>
				<th class="ct" >编写</th>
				<th class="ct" >停电时间</th>
				<th class="ct" >总负责人</th>
				<th class="ct" >状态</th>
			</tr>
			<c:forEach items="${list}" var="Tab" >
					<tr>
						<td >
								<c:set value="${Tab.id}," var="varName" />
								<c:if test='${fn:contains(hiddenids, varName)}'>
									<input type="checkbox" name="id" value="${Tab.id}" checked onClick="getAllIds(this)"/>
								</c:if>
								<c:if test='${fn:contains(hiddenids, varName) == false}'>
									<input type="checkbox" name="id" value="${Tab.id}" onClick="getAllIds(this)"/>
								</c:if>
						</td>
						<td>
							<a href="#" onClick="javascript:toDetail('<c:out value="${Tab.id}"/>','<c:out value="${searchBean.con20}"/>')" >
								${Tab['famc']}
							</a>
						</td>
						<td>${Tab['shname']}</td>
						<td>${Tab['bxname']}</td>
						<td>
							<fmt:formatDate value="${Tab.tdsj}" pattern="yyyy-MM-dd"/>&nbsp;
						</td>
						<td>${Tab['zfzr']}</td>
						<td>
						<c:choose>
							<c:when test="${Tab.status == '1'}">待提交</c:when>
							<c:when test="${Tab.status == '2'}">班组填写</c:when>
							<c:when test="${Tab.status == '3'}">工区审核</c:when>
							<c:when test="${Tab.status == '4'}">审核通过</c:when>
							<c:when test="${Tab.status == '5'}">审核未通过</c:when>
						</c:choose>
						</td>
					</tr>
				</c:forEach>

				<c:if test="${list == null || fn:length(list) == 0 }">
					<tr>
						<td colspan="9" style="text-align: center">
							无相关记录
						</td>
					</tr>
				</c:if>
		</table>
			<table width="100%" id="tablestyle2">
			<tr>
				<td>
					<hr />
				</td>
			</tr>
			<tr>
				<td>${pageDown}</td>
			</tr>
		</table>
	</form>
  </body>
  <script>

		// 查询
		function cmt(){
			document.frmM.action = "<%=contextPath%>/planList!getList.do?page=1&c=c";
			document.frmM.submit();
		}
   
   		// 新建修改进入详细页面
		function toDetail(id,whichmenu){
			location.href = "<%=contextPath%>/jxfa!initJxfaDetail.do?id=" + id + "&searchBean.con20=" + whichmenu;
		}
	

		// 删除
		function deleteIt()
		{
			if(!isChecked("id")) {
		 		alert("请选择要删除的记录");
		 		return false;
		 	}
		    if(confirm("确定要删除选中的记录吗？")) {
		       	document.frmM.action = "<%=contextPath%>/jxfa!deleteJxfa.do?";
				document.frmM.submit();
		    }
		}
			
		// 点击checkbox 获得选中的id 给 hidden
		function getAllIds(obj) {
			
				var hiddenids = document.getElementById("hiddenids").value;
				
				var thisid = obj.value;
				var chkflag = obj.checked;
				
				if (chkflag) {
					if (hiddenids == "") {
						hiddenids = "," + thisid + ",";
					} else {
						hiddenids += thisid + ",";
					}
				} else {
					
					if (hiddenids.indexOf("," + thisid + ",") != -1) {
					
						hiddenids = hiddenids.replace(("," + thisid + ","), ",");
					}
				}
				
				if (hiddenids == ",") {
					hiddenids = "";
				}
				
				 document.getElementById("hiddenids").value = hiddenids;
		}
		
		//提交
		function toConfirm(flag)
		{
		
				var msg = flag == '2' ? '提交':'审核通过';
				if(!isChecked("id")) {
		 			alert("请选择要" + msg + "选中的记录");
		 			return false;
		 		}
		    	if(confirm("确定要" + msg + "选中的记录吗？")) {
		        	document.frmM.action = "<%=contextPath%>/jxfa!confirmJxfa.do?flag=" + flag;
					document.frmM.submit();
		    	}
		}		
		
	</script>
</html>
